<!--
    Copyright 2010 Justin Lipton, Jonathan Rosenberg
    
    This file is part of MediaList.

    MediaList is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    MediaList is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with MediaList.  If not, see <http://www.gnu.org/licenses/>.
-->


<html>
    <head>
        <title>MediaList</title>
        <script type="text/javascript" src="show.js"></script>
        <script type="text/javascript" src="addShow.js"></script>
        <link rel="stylesheet" type="text/css" href="main.css" />
    </head>
    
    <body bgcolor=white>
        <div class=mainHeader>MediaList!</div>
        <div class=mainBody>

            <table width='942'>
            <tr valign='top'>
            <td width='200'>
            <?php
            
                $db = new mysqli("localhost", "root",null , "DB");
                if(mysqli_connect_error()) echo "error 2";
                $stmt = $db -> prepare("SELECT * FROM shows WHERE ShowID=?");
                $stmt -> bind_param("s", $_GET["showID"]);
                $stmt -> execute();
                $stmt -> bind_result($row['ShowId'], $row['Showname'], $row['ForumLink'], $row['NumEpisodes'], 
                                     $row['EpisodeLength'], $row['Summary'], $row['WhenMade'], $row['TotalScores'], 
                                     $row['TotalSeen'], $row['TotalFav']);
                $stmt -> fetch();

                if(!file_exists('show_pictures/' . $_GET['showID'] . '.jpg'))
                {
                    echo '<img src = show_pictures/00.jpg width = \'200\' height = \'200\'/><br />';
                }
                else
                {
                    echo '<img src = show_pictures/' . $_GET['showID'] . ".jpg width = '200' height = '200'/><br />";
                }
                
                
                echo '<span id="showError">';
                echo '<a href="javascript:addShow(\'' .$row['Showname'] .'\');"> Add Show </a><br />';
                echo '</span>';
                
                
                echo '<table>';
                echo '<tr><td>Number of Episodes: </td><td>' . $row["NumEpisodes"] . '</td></tr>';
                echo '<tr><td>Episode Length: </td><td>' . $row["EpisodeLength"] . '</td></tr>';
                if($row['TotalSeen'] == 0)
                {
                  $averageRating = 'NA';
                }
                else
                {
                  $averageRating = $row["TotalScores"] / $row['TotalSeen'];
                }
                echo '<tr><td>Average Score: </td><td>' . $averageRating . '</td></tr>';
                echo '<tr><td>Total Views: </td><td>' . $row['TotalSeen'] . '</td></tr>';
                echo '<tr><td>Total Favorites: </td><td>' . $row["TotalFav"] . '</td></tr>';
                echo '</table></td>';
                
                echo '<td width=\'742\'><b>' . $row["Showname"] . '</b><table>';

                echo '<tr><td>Summary: <br /> ' . $row['Summary'] . '</td></tr>';

                echo '<tr><td> <b>Compatable Show Placeholder </b></td></tr>';
                
                echo '<tr><td><b> Reviews Placeholder </b></td></tr>';

                echo '</table>';

            ?>
            </td>
            </tr>
        </div>
        <br/>

    </body>
</html>